package com.portal.admin.base.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.portal.admin.base.enums.SystemType;
import com.portal.admin.utils.session.SessionUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 基础类
 */
public class BaseEntity implements Serializable {
    protected String id;	// id
    protected String createBy;	// 创建者
    @JSONField(serialize = false)
    protected Date createDate;	// 创建日期
    @JSONField(serialize = false)
    protected String updateBy;	// 更新者
    @JSONField(serialize = false)
    protected Date updateDate;	// 更新日期
    @JSONField(serialize = false)
    protected Integer delFlag; // 删除标记（0：正常；1：删除）
    @JSONField(serialize = false)
    @TableField(exist = false)
    protected List<String> fileList = new ArrayList<>(); //附件信息

    public List<String> getFileList() {
        return fileList;
    }

    public void setFileList(List<String> fileList) {
        this.fileList = fileList;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    //新增方法前
    public void preInsert() {
        String userId = SessionUtils.getCurrentUserId();
        Date currentTime = new Date();
        this.createBy =userId;
        this.createDate =currentTime;
        this.updateBy =userId;
        this.updateDate =currentTime;

    }
    //修改方法前
    public void preUpdate(){
        String userId = SessionUtils.getCurrentUserId();
        this.updateBy =userId;
        this.updateDate =new Date();
    }

    public String getCreateBy() {
        return createBy;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public String getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(String updateBy) {
        this.updateBy = updateBy;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public Integer getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(Integer delFlag) {
        this.delFlag = delFlag;
    }
}
